package com.orm.session;


/**
 * 构建Mapper 的工厂
 */
public class MapperFactory {
	private DefaultSqlSessionFactory defaultSqlSessionFactory;
	private String mapperInterface;     // 目标mapper接口全类名
	
	public void setSqlSessionFactory(DefaultSqlSessionFactory defaultSqlSessionFactory) {
		this.defaultSqlSessionFactory = defaultSqlSessionFactory;
	}
	
	public void setMapperInterface(String mapperInterface) {
		this.mapperInterface = mapperInterface;
	}
	
	public <T> T getMapper(Class<T> clazz) {
		return defaultSqlSessionFactory.openSession().getMapper(clazz);
	}
}
